#include <cstdio>
#include <iostream>
using namespace std;

typedef unsigned int uint;
#define MAX_N 10001

uint last_digit[MAX_N] = {0, 1};

inline void init ()
{
	uint f = 1, i, aux;
	for( i = 2; i < MAX_N; ++i )
	{
		aux = i;
		while( aux % 10 == 0 )
			aux /= 10;
		aux %= 10;
		f *= aux;
		while( f % 10 == 0 )
			f /= 10;
		f %= 10;

		last_digit[i] = f;
		cerr << "\ti: " << i
			<< "\t\taux: " << aux
			<< "\t\tf: " << f
			<< endl;
	}
}


int main ()
{
	uint n;

	init();

	while( scanf( "%u", &n ) == 1 )
	{
		printf( "%5u -> %u\n", n, last_digit[n] );
	}

	return 0;
}